package ControleAcamico;

import java.sql.SQLException;

import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;

import ControleDiversas.AdicionarTurmaJBDC;
import VisaoControleAcademico.PainelPrincipal;

public class ClalseAlterarTurma {
public static 	Object item;
public static 	String newitem;
	public static void altera() {
		ListSelectionModel selmodel = PainelPrincipal.listaProfessor.getSelectionModel();
		int index = selmodel.getMinSelectionIndex();
		if (index == -1)
			return;
		item = PainelPrincipal.modelo.getElementAt(index);
		String text = JOptionPane.showInputDialog("Alterar o Nome Do item", item);
		newitem = null;

		if (text != null) {
			newitem = text.trim();
		} else
			return;

		if (!newitem.isEmpty()) {
			PainelPrincipal.modelo.remove(index);
			PainelPrincipal.modelo.add(index, newitem);
		}
		new AdicionarTurmaJBDC().alterarTurma();	
	
	}

}
